<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
    <base href="<%=basePath%>">
    <title></title>
    <meta http-equiv="cache-control" content="no-cache">

    <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
    <link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>

    <script>
        function show(pageIndex){
            window.location.href="RoleServlet?flag=listadmin&pageIndex="+pageIndex;
        }
    </script>

    <style>
        .waiting-allocation {
            color: red;
        }
    </style>

</head>

<body>
<div class ="div_title">
    <div class="div_titlename"> <img src="/images/san_jiao.gif" ><span>管理人员基本信息列表</span></div>
</div>

<form action="AdminServlet"  name="form1">
    <input name="flag" value="deleteChecked" type="hidden">

    <table class="main_table" >
        <tr>
            <th>账号</th> 	<th>状态</th>	<th>用户角色</th>  <th>最后更新日期</th> 	<th>操作</th>
        </tr>
        <c:forEach items="${adminList}" var="a">
            <tr>

                <td>${a.adminName}
                <td>
                    <c:if test="${a.state=='1'}">
                        正常
                    </c:if>
                    <c:if test="${a.state=='2'}">
                        锁定
                    </c:if>
                </td>
                <td>
                    <c:if test="${a.roleId!=null}">
                        ${a.roleName}
                    </c:if>
                    <c:if test="${a.roleId==''}">
                        <span class="waiting-allocation">等待分配权限</span>
                    </c:if>
                </td>
                <td>
                    <fmt:formatDate value="${a.editDate }"  pattern="yyy-MM-dd HH:mm"/>
                </td>
                <td>

                    <a href="RoleServlet?flag=roleUse&id=${a.id}">角色分配</a>

                </td>
            </tr>

        </c:forEach>
    </table>
</form>

<div class="div_page" >
    <div class="div_page_left">    共有 <label>${page.rowCount}</label> 条记录，当前第 <label>${page.pageIndex}</label> 页，共 <label>${page.pageCount}</label> 页	</div>
    <div class="div_page_right" >

        <c:choose>
            <c:when test="${page.hasPre }">
                <button onclick="show(1)"> 首页</button>
                <button onclick="show(${page.pageIndex-1})"> 上一页</button>
            </c:when>
            <c:otherwise>
                首页
                上一页
            </c:otherwise>
        </c:choose>

        <c:choose>
            <c:when test="${page.hasNext }">
                <button onclick="show(${page.pageIndex+1})">  下一页 </button>
                <button onclick="show(${page.pageCount})"> 尾页</button>
            </c:when>
            <c:otherwise>
                下一页
                尾页
            </c:otherwise>
        </c:choose>


        <button onclick="show(document.getElementById('pageIndex').value)">转到</button>
        <input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex }" /> 页

    </div>

</div>

</body>
</html>